﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Returns all the information about a known place.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.GeoToolbox.bmp")]
    [Designer(typeof(GetPlaceDeisgner))]
    [Description("Returns all the information about a known place.")]
    public class GetPlace : TwitterOperationInvoker<Place>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetPlace"/> class.
        /// </summary>
        public GetPlace()
            : base("GetPlace")
        { }

        /// <summary>
        /// A place in the world. These IDs can be retrieved from ReverseGeoCode
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// The place ID.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [RequiredArgument]
        [Description("A place in the world. These IDs can be retrieved from ReverseGeoCode")]
        public InArgument<string> PlaceID { get; set; }

        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            RuntimeArgument idArgument = new RuntimeArgument("PlaceID", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(PlaceID, idArgument);
            metadata.AddArgument(idArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("placeID", PlaceID);

            base.Execute(context);
        }
    }
}
